package easyexcel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

/**
 * easyexcel导入导出 动态列
 */
public class EasyExcelFirst {
    public static void main(String[] args) throws FileNotFoundException {
        String fileName ="C:\\Users\\huxin\\Desktop\\视频源区块模板.xlsx";
//                TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 然后千万别忘记 finish
//        EasyExcel.read(fileName, DemoData.class, new DemoHeadDataListener()).sheet().doRead();
        FileInputStream fileInputStream = new FileInputStream(new File(fileName));
        List<Object> objects = EasyExcel.read(fileInputStream, new DemoHeadDataListener2()).sheet().doReadSync();
        for (Object object : objects) {
            System.out.println(JSON.toJSONString(object));
        }
        try {
            fileInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
